#ifndef CRICKET_EXAMPLES_CALL_CONSOLE_H__
#define CRICKET_EXAMPLES_CALL_CONSOLE_H__

#include "base/thread.h"
#include "base/messagequeue.h"

class CallClient;

enum {
	MSG_START,
	MSG_INPUT,
};

class Console : public talk_base::MessageHandler {
 public:
  Console(talk_base::Thread *thread, CallClient *client);
  virtual void OnMessage(talk_base::Message *msg);
  void SetPrompt(const char *prompt) {
	  prompt_ = prompt ? std::string(prompt) : std::string("call");
  }
  void SetPrompting(bool prompting) {
    prompting_ = prompting;
    if (prompting)
	  printf("\n(%s) ", prompt_.c_str());
    }
  bool prompting() {return prompting_;}

  void Print(const char* str);
  void Print(const std::string& str);
  void Printf(const char* format, ...);
 private:
  CallClient *client_;
  talk_base::Thread *client_thread_;
  void StartConsole();
  void ParseLine(std::string &str);
  std::string prompt_;
  bool prompting_;
};

#endif // CRICKET_EXAMPLES_CALL_CONSOLE_H__

